{% extends 'personInfoBase.html' %}
{% block personInfoContentRight %}

    {% if cardDirlist %}
        {% for  card in cardDirlist %}
            <div class="panel panel-default">
                    <!-- Default panel contents -->
                    <div class="panel-heading">卡{{loop.index}}</div>
                    <div class="panel-body">
                        <p>卡号：</p>
                      <h1>{{card.number}}</h1>
                      <button type="button" class="btn btn-primary" onclick="location.href='/personInfo/loadsecret/'+'{{card.number}}'">下载密钥</button>
                    </div>
                  
                    <!-- Table -->
                    <table class="table">
                      <tr>
                          <td>创建时间：</td>
                          <td>{{getTimeFromtimeStamp(card.createTime)}}</td>
                      </tr>
                      <tr>
                          
                          <td><button type="button" class="btn btn-primary"   onclick="onQuery('{{card.number}}','{{loop.index}}')">余额查询</button></td>
                          <td id ="cardQuery{{loop.index}}"></td> 
                          <td style="text-align:right;"><button type="button" class="btn btn-primary"   onclick="transferByaddress('{{card.number}}')">转账</button></td>
                        
                      </tr>
                    </table>
                    
            </div>
        {% endfor %}
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">时间银行卡操作</div>
            <div class="panel-body">
            </div>
          
            <!-- List group -->
            <ul class="list-group">
              <li class="list-group-item"><a  text-align=“center” href="{{url_for("personInfouploadsecret")}}" >绑定时间银行卡</a></li>
              <li class="list-group-item"><a  text-align=“center” href="{{url_for("registerNewCard")}}" >注册新卡</a></li>
            </ul>
        </div>
       
    {% else %}
    <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">当前账户下还没有绑定时间银行卡</div>
            <div class="panel-body">
            </div>
          
            <!-- List group -->
            <ul class="list-group">
              <li class="list-group-item"><a  text-align=“center” href="{{url_for("personInfouploadsecret")}}" >绑定时间银行卡</a></li>
              <li class="list-group-item"><a  text-align=“center” href="{{url_for("registerNewCard")}}" >注册新卡</a></li>
            </ul>
    </div>
    
        
    {% endif %}
    <script>
        function transferByaddress(senderaccount){
            location.href="/transferAccounts/"+senderaccount

        }
        function onLoadFile(card,filename){
            location.href="/personInfo/loadsecret/"+card+ "/" +filename
        }
        function onQuery(address,index){
            var qid='cardQuery' + index
            $.ajax({
			//几个参数需要注意一下
				type: "POST",//方法类型
				dataType: "json",//从服务端返回的数据类型
				url: "/balancequery/" +address,//url
				success: function (result) {
					//alert(result.message);//打印服务端返回的数据(调试用)
					if(result.status== 500){
                       
                        $('#'+qid).text(result.balance)
						//window.location.href="/personInfo/accountlist";
					}
                    else{
                        $('#'+qid).text("请稍后查询")
                    }
				}
				// alert(data.message);
				// if(data.message.indexOf("注册成功")>=0){
				// 	jQuery.getJSON("/shopping/admin/sync_user_info.htm?userIds="+data.userId);
				// 	//设置参数并跳转
				// 	window.location.href="/timebank/welcome/front/mybank.action";
				// }

				});
        }
    </script>

{% endblock %}